﻿using Sunny.UI;
using System.Threading;
using System;
using System.Windows.Forms;
using System.IO;
using CoreShop.Services;
using System.Data;
using CoreShop.Model.UI;
using CoreShop.Model;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using CoreShop.Model.FromBody;
using CoreShop.Library;
using static CoreShop.Model.FromBody.FPosUserPost;
using System.Linq.Expressions;
using System.Collections.Specialized;
using CoreShop.Services.Services.System;
using System.Threading.Tasks;
using Sunny.UI.Win32;
using SqlSugar;
using NPOI.SS.Formula.Functions;
using System.Drawing;
using CoreShop.App.Units.Interface;
using System.Diagnostics;
using CoreShop.App.Test;
using MySqlX.XDevAPI.Common;

namespace CoreShop.App
{
    public partial class fpgDataMonitor : UIPage
    {
        static System.Timers.Timer timer_data = null;
        private int iTime_data = 0;
        private int syncType = 1;
        private int mallOrderCount = 0;//统计最新订单数        

        public fpgDataMonitor()
        {
            InitializeComponent();
            if (timer_data == null)
            {
                timer_data = new System.Timers.Timer();
                timer_data.Interval = 1000;
                timer_data.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
                timer_data.Enabled = true;
            }
        }

        private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            try
            {                
                timer_data.Enabled = false;
                iTime_data = iTime_data + 1;
                int checkTimes = AppConstVars.systemsetup.checkTimes * 60;

                if ((checkTimes > 0) && (iTime_data % checkTimes == 0))
                {
                    string msg = "";
                    var sysRecordEntity = new SyncUtil().GetSysRecordEntity(AppConstVars.sysUser, ref msg);
                    int myMallOrders = MallOrderUtil.GetOrderCount();
                    if (mallOrderCount != myMallOrders)
                    {
                        if (myMallOrders > 0)
                            Program.frmOrdering.btnMallOrder.TipsText = myMallOrders.ToString();
                        else
                            Program.frmOrdering.btnMallOrder.TipsText = "";
                        mallOrderCount = myMallOrders;                        
                    }
                    A_SynDataAsync(sysRecordEntity);
                }
                else 
                if (iTime_data % AppConstVars.systemsetup.downBaseTimes == 0 || syncType == 1)
                {
                    A_SynDataAsync();
                }
                if (iTime_data % AppConstVars.systemsetup.uploadTimes == 0)
                {
                    A_UpLoadData();
                    A_UpLoadMallOrder();
                }
                if ((iTime_data > AppConstVars.systemsetup.downBaseTimes) && (iTime_data > AppConstVars.systemsetup.uploadTimes))
                {
                    iTime_data = 0;
                }
            }
            catch (Exception ex)
            {
                DataExc_SetLog(DateTime.Now.ToString() + "  数据同步出错：" + ex.Message + "\r\n");
            }
            finally
            {
                timer_data.Enabled = true;
                syncType = 0;
            }
        }

        #region 上传商品销售数据
        /// <summary>
        /// 上传商品销售数据
        /// </summary>
        public async void A_UpLoadData()
        {            
            try
            {
                DataExc_SetLog(DateTime.Now.ToString() + "  开始启动定时上传任务" + "\r\n");
                if (AppConstVars.sysUser == null)
                {
                    DataExc_SetLog(DateTime.Now.ToString() + "  未获取登录用户信息，上传失败" + "\r\n");
                    return;
                }

                var masterServices = new corecmsfoodordermasterServices();               

                var orderIds = masterServices.AsQueryable().Where(p=>p.isUpload == false).Select(p => p.orderId).ToList();
                if ((orderIds == null) || (orderIds.Count == 0))
                {
                    DataExc_SetLog(DateTime.Now.ToString() + "  没有可上传的销售数据" + "\r\n");
                    return;
                }

                foreach (var orderId in orderIds)
                {
                    var postData = new OrderBusiness().GetUpLoadOrderData(AppConstVars.sysUser, AppConstVars.sysStore, AppConstVars.classNumber, orderId);
                    var result = await OrderApiUtil.SendOrderAsync(postData);
                    if (result != null)
                    {
                        if ((result.code == 200) || ((result.code == 30001) && (result.msg.IndexOf("重复") > 0)))
                        {
                            masterServices.UpdateUpLoadById(orderId);
                            DataExc_SetLog(DateTime.Now.ToString() + "销售数据上传完成" + "\r\n");
                        }
                        else
                        {
                            DataExc_SetLog(DateTime.Now.ToString() + "销售数据上传出错" + result.msg.ToString() + "\r\n");
                        }
                    }                    
                }
            }
            catch (Exception ex)
            {
                DataExc_SetLog(DateTime.Now.ToString() + "销售数据上传出错：" + ex.Message + "\r\n");
            }
        }
        #endregion


        #region 上传线上订单数据
        /// <summary>
        /// 上传商品销售数据
        /// </summary>
        public async void A_UpLoadMallOrder()
        {
            try
            {
                var masterServices = new corecmsordermasterServices();

                var orderIds = masterServices.AsQueryable().Where(p => p.checkFlag == true && p.isUpload == false).Select(p => p.id).ToList();
                if ((orderIds == null) || (orderIds.Count == 0))
                {
                    DataExc_SetLog(DateTime.Now.ToString() + "  没有可上传的线上订单数据" + "\r\n");
                    return;
                }

                foreach (var orderId in orderIds)
                {
                    await MallOrderUtil.SetUpLoadOrderDataAsync(orderId);
                }
            }
            catch (Exception ex)
            {
                DataExc_SetLog(DateTime.Now.ToString() + "线上订单上传出错：" + ex.Message + "\r\n");
            }
        }
        #endregion


        /// <summary>
        /// 上传数据后返回会员更新
        /// </summary>
        private void SetMemberResult(object list)
        {
            if (list == null) return;
            try
            {
                var memberList = list as List<GetPosUserPost>;
                if (memberList == null) return;
                foreach (var member in memberList)
                {
                    var bl = new corecmsuserServices().Update(a => new corecmsuser()
                    {
                        balance = member.balance,
                        giftBalance = member.giftBalance,
                        point = member.point,
                    }, a => a.id == member.id);
                }
            }
            catch { }
        }

        #region 与后台Redis的PosExchangeModel进行判断

        private corecmsexchange GetCorecmsExchange()
        {
            try
            {
                var corecmsexchangeSvr = new corecmsexchangeServices();
                var exchange = corecmsexchangeSvr.GetDataById(AppConstVars.sysUser.storeId);

                if (!string.IsNullOrEmpty(exchange.content))
                    exchange.timeStampPos = JsonConvert.DeserializeObject<PosExchangeModel>(exchange.content);
                else
                {
                    exchange.timeStampPos = new PosExchangeModel();
                    exchange.timeStampPos.storeId = AppConstVars.sysUser.storeId;
                    exchange.content = JsonConvert.SerializeObject(exchange.timeStampPos);
                    new corecmsexchangeServices().UpdateAsync(new corecmsexchange { storeId = AppConstVars.sysUser.storeId, content = exchange.content });
                }

                string channel = string.Format(":{0}/Interface/GetDataTimestamp", AppConstVars.sysUser.channel == 0 ? "" : AppConstVars.sysUser.channel.ToString());
                string url = AppConstVars.systemsetup.corehubUrl + channel;
                AppConstVars.sysUser.corehubUrl = url;
                return exchange;
            }
            catch (Exception ex) 
            {
                DataExc_SetLog(DateTime.Now.ToString() + string.Format("错误：GetCorecmsExchange,{0}",ex.Message) + "\r\n");
            }
            return null;
        }

        #endregion

        /// <summary>
        /// 检查是否要进行与从后台同步数据
        /// </summary>
        /// <param name="RecordEntity"></param>
        /// <param name="recordName"></param>
        /// <returns></returns>
        public bool CheckSyncTime(List<sysrecordentity> RecordEntitys,string recordName)
        {
            if (RecordEntitys == null) return true;//当RecordEntitys为空时，要同步数据
            var sysrecordentity = RecordEntitys.Find(p => p.recordName == recordName);
            if (sysrecordentity == null) return false;//没有记录说明没有新的数据，不同步
            if (sysrecordentity.recordTime == sysrecordentity.thisRecordTime) return false;//时间相同不进行同步
            return true;
        }

        public async void A_SynDataAsync(List<sysrecordentity> RecordEntity = null)
        {
            var remoteService = new PosRemoteServices(AppConstVars.sysUser.ccessToken);
            string msg = "";
            try
            {
                //AppConstVars.mut_DownLoad.WaitOne();
                DataExc_SetLog(DateTime.Now.ToString() + "  开始启动定时下载任务" + "\r\n");

                //if (AppConstVars.sysUser == null) SysClass.GetSysPara();
                if (AppConstVars.sysUser == null)
                {
                    DataExc_SetLog(DateTime.Now.ToString() + "  未获取登录用户信息，下载失败" + "\r\n");
                    return;
                }

                var exchange = GetCorecmsExchange();
                if (exchange == null)
                {
                    DataExc_SetLog(DateTime.Now.ToString() + "  没有找到下载信息数据表，下载中断" + "\r\n");
                    return;
                }

                int rowCount = 0;
                AppConstVars.exchange = exchange;
                exchange.status = true;
                long storeId = AppConstVars.sysUser.storeId;
                string token = AppConstVars.sysUser.ccessToken;
                AppConstVars.sysStore = new corecmsstoreServices().GetById(storeId);
                if (AppConstVars.sysStore == null)
                {
                    DataExc_SetLog(DateTime.Now.ToString() + "  未获取登录门店信息，下载失败" + "\r\n");
                    return;
                }

                //1、商城订单
                if (CheckSyncTime(RecordEntity, SyncUtil.RecordTableName.MallOrder))
                {
                    rowCount = new MallOrderUtil().LoadOrderNum(exchange);
                    DataExc_SetLog(DateTime.Now.ToString() + "  1、下载更新商品分类资料" + rowCount.ToString() + "条\r\n");
                }

                //2、商品分类
                if (CheckSyncTime(RecordEntity, SyncUtil.RecordTableName.GoodCategory))
                {
                    rowCount = remoteService.GetGoodCategoryList(AppConstVars.sysStore, AppConstVars.sysUser, exchange, ref msg);
                    DataExc_SetLog(DateTime.Now.ToString() + "  2、下载更新商品分类资料" + rowCount.ToString() + "条\r\n");
                }

                //3、商品资料
                if (CheckSyncTime(RecordEntity, SyncUtil.RecordTableName.GoodData))
                {
                    //List<corecmsfood> foodList = new List<corecmsfood>();
                    //rowCount = remoteService.GetGoodDataList(AppConstVars.sysStore, AppConstVars.sysUser, exchange, ref foodList, ref msg);
                    var goodsResult = await FoodApiUtil.GetGoodDataList(AppConstVars.sysStore, AppConstVars.sysUser, exchange);
                    if ((goodsResult.count > 0) && goodsResult.foodList != null)
                    {
                        Program.frmOrdering.BindFoodRefresh(goodsResult.foodList);
                        new FoodUtil().DownProductImage(goodsResult.foodList);
                    }
                    DataExc_SetLog(DateTime.Now.ToString() + "  3、下载更新商品资料" + goodsResult.count.ToString() + "条\r\n");
                    if ((goodsResult.code == 0) && (!string.IsNullOrEmpty(goodsResult.msg)))
                        DataExc_SetLog(DateTime.Now.ToString() + "  3、下载商品=>" + goodsResult.msg.ToString() + "\r\n");
                }

                //4、促销活动
                if (CheckSyncTime(RecordEntity, SyncUtil.RecordTableName.Activity))
                {
                    DataExc_SetLog(DateTime.Now.ToString() + "  4、开始下载促销活动数据\r\n");
                    rowCount = new ActivitieUtil().GetActivityList(exchange, ref msg);
                    DataExc_SetLog(DateTime.Now.ToString() + " 4、开始下载促销活动数据" + rowCount.ToString() + "条\r\n");
                }

                //5、商品调价
                if (CheckSyncTime(RecordEntity, SyncUtil.RecordTableName.GoodChgPrice))
                {
                    var reslut = await FoodApiUtil.GetGoodChgPriceList(AppConstVars.sysStore, AppConstVars.sysUser, exchange);
                    DataExc_SetLog(DateTime.Now.ToString() + "  5、下载更新商品调价" + reslut.total.ToString() + "条\r\n");
                    if (!string.IsNullOrEmpty(reslut.msg)) DataExc_SetLog(DateTime.Now.ToString() + reslut.msg);
                }

                //6、副屏广告
                if (CheckSyncTime(RecordEntity, SyncUtil.RecordTableName.ScreemImg))
                {
                    new ScreemImgService().GetScreemImgList(AppConstVars.sysUser, AppConstVars.sysStore, exchange);
                    DataExc_SetLog(DateTime.Now.ToString() + "  6、下载更新副屏广告\r\n");
                }

                //7、商品单位
                if (CheckSyncTime(RecordEntity, SyncUtil.RecordTableName.GoodUnit))
                {
                    rowCount = remoteService.GetGoodUnitList(AppConstVars.sysStore, AppConstVars.sysUser, exchange, ref msg);
                    DataExc_SetLog(DateTime.Now.ToString() + "  7、下载商品单位资料\r\n");
                }

                if (syncType == 1)
                {
                    //7、前台参数设置
                    if (CheckSyncTime(RecordEntity, SyncUtil.RecordTableName.PosPara))
                    {
                        DataExc_SetLog(DateTime.Now.ToString() + "  8、开始下载参数数据\r\n");                        
                        rowCount = remoteService.GetPosPara(AppConstVars.sysStore, AppConstVars.sysUser, exchange, ref msg);
                        if (rowCount > 0)
                        {
                            ProcessUtil.GetSystemSetup();
                            DataExc_SetLog(DateTime.Now.ToString() + "  8、开始下载参数数据" + rowCount.ToString() + "条\r\n");
                        }
                        if (exchange.code == 200)
                        {
                            DataExc_SetLog(DateTime.Now.ToString() + "  8、检测登录用户数据失效\r\n");                            
                            LoginByPosThread();
                        }
                    }

                    //8、用户权限
                    if (CheckSyncTime(RecordEntity, SyncUtil.RecordTableName.UserRouters))
                    {
                        DataExc_SetLog(DateTime.Now.ToString() + "  9、开始下载用户权限数据\r\n");
                        SystemApiUtil.GetUserRoleInfo(AppConstVars.sysUser);
                        SystemApiUtil.GetUserRouters(AppConstVars.sysUser);
                        DataExc_SetLog(DateTime.Now.ToString() + "  9、完成下载用户权限数据\r\n");
                    }

                    //9、营业员资料
                    if (CheckSyncTime(RecordEntity, SyncUtil.RecordTableName.Employee))
                    {
                        rowCount = remoteService.GetEmployeeList(AppConstVars.sysStore, AppConstVars.sysUser, exchange, ref msg);
                        DataExc_SetLog(DateTime.Now.ToString() + "  9、下载营业员资料" + rowCount.ToString() + "条\r\n");
                    }

                    //10、下载收款方式
                    if (CheckSyncTime(RecordEntity, SyncUtil.RecordTableName.BalanceType))
                    {
                        //var paylist = remoteService.GetBalanceType(AppConstVars.sysStore, AppConstVars.sysUser, exchange, ref msg);
                        var paylist = await SystemApiUtil.GetBalanceType();
                        if (paylist != null) DataExc_SetLog(DateTime.Now.ToString() + "  10、下载收款方式" + paylist.Count.ToString() + "条\r\n");
                    }
                }

                //没有报错，保存下载记录
                if (exchange.status)
                    new corecmsexchangeServices().UpdateAsync(exchange);

                //SysGoodsService.SetCompressGoodsImg();//处理大的图片
                DataExc_SetLog(DateTime.Now.ToString() + "  数据下载完成" + "\r\n");
            }
            catch (Exception E)
            {
                DataExc_SetLog(E.Message + "  数据下载出错" + "\r\n");
            }
            finally
            {
                //AppConstVars.mut_DownLoad.ReleaseMutex();
                syncType = 0;
            }
        }

        public void LoginByPosThread()
        {
            var newThread = new Thread(() => LoginByPos(), 1024 * 512);
            newThread.IsBackground = true;
            newThread.Start();
        }

        public async void LoginByPos()
        {
            string password = Security.Decrypt(AppConstVars.sysUser.passWord);
            await SystemApiUtil.GetUserLogin(AppConstVars.sysUser.userName, password);
        }

        private void DataExc_ClearProgress()
        {
            this.Invoke(new Action(() =>
            {
                this.uiProcessBar1.Value = 0;
                this.lbl_msg.Text = "";
                this.uiProcessBar1.Visible = true;
                this.lbl_msg.Visible = true;
            }));
        }

        public void DataExc_SetLog(string msg)
        {
            try
            {
                rtxDataLog.Invoke(new Action(() =>
                {
                    if (rtxDataLog.Text.Length > 3000) rtxDataLog.Clear();
                    rtxDataLog.AppendText(msg);
                    rtxDataLog.HideSelection = false;
                }));
            }
            catch { }
        }

        private void addMsg(string title, string msg)
        {
            rtxDataLog.Invoke(new MethodInvoker(delegate
            {
                if (rtxDataLog.Text.Length > 9000)
                {
                    LogManager.WriteTxtLog(rtxDataLog.Text);
                    rtxDataLog.Text = "";
                }
                rtxDataLog.Text += System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "/" + title + ": " + msg + "\r\n";
            }));
        }

        private void DataExc_SetProgressMax(int MaxValue)
        {
            this.Invoke(new Action(() =>
            {
                this.uiProcessBar1.Maximum = MaxValue;
                this.lbl_msg.Text = string.Format("进度:{0}/{1}", 0, this.uiProcessBar1.Maximum);
                this.lbl_msg.Visible = true;
                this.uiProcessBar1.Visible = true;
            }));
        }

        private void DataExc_SetProgress(int value)
        {
            this.uiProcessBar1.Invoke(new Action(() =>
            {
                if (value <= this.uiProcessBar1.Maximum)
                {
                    this.uiProcessBar1.Value = value;
                    this.lbl_msg.Text = string.Format("进度:{0}/{1}", value, this.uiProcessBar1.Maximum);
                }                    
            }));

        }

        private void btnExchangData_Click(object sender, System.EventArgs e)
        {
            syncType = 1;
            AppConstVars.SynDataFlag = true;
            btnExchangData.Enabled = false;
            btnStockDataEx.Enabled = true;
            timer_data.Stop();
            timer_data.Enabled = false;
            DataExc_SetLog(DateTime.Now.ToString() + "  开始启动定时下载任务。\r\n");
            Task.Factory.StartNew(() => { A_SynDataAsync(); }).TaskDis();
            Task.Factory.StartNew(() => { A_UpLoadData(); }).TaskDis();                      
            timer_data.Enabled = true;
            timer_data.Start();
        }

        private void btnStockDataEx_Click(object sender, EventArgs e)
        {
            AppConstVars.SynDataFlag = false;
            timer_data.Stop();
            timer_data.Enabled = false;
            btnExchangData.Enabled = true;
            btnStockDataEx.Enabled = false;
            this.uiProcessBar1.Invoke(new Action(() =>
            {
                this.uiProcessBar1.Value = 0;
            }));
        }

        private void btnClearLog_Click(object sender, EventArgs e)
        {
            this.rtxDataLog.Invoke(new Action(() =>
            {
                rtxDataLog.Text = "";
            }));
        }

        private void fpgDataMonitor_ReceiveParams(object sender, UIPageParamsArgs e)
        {
            syncType = CommFunc.ConvertToInt32(e.Value);//0定时下载，1手动实时下载
            if (syncType == 1)
            {
                timer_data.Enabled = false;
                btnClearLog_Click(null, null);
                Task.Factory.StartNew(() =>
                {
                    btnExchangData_Click(null, null);
                }).TaskDis();
            }
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            Program.frmMainWin.ShowNavigation();
        }

        private void btnRunSql_Click(object sender, EventArgs e)
        {
            try
            {
                string msql = rtxDataLog.Text;
                new DataHelper().ExecuteCommand(msql);
                DataExc_SetLog(DateTime.Now.ToString() + "  执行完成。\r\n");
            }
            catch (Exception ex)
            {
                DataExc_SetLog(DateTime.Now.ToString() + string.Format("  错误{0}。\r\n", ex.Message));
            }
        }

        private void fpgDataMonitor_Load(object sender, EventArgs e)
        {

        }

        private void btnOprt_Click(object sender, EventArgs e)
        {
            btnOprt.ShowContextMenuStrip(cmsOpration, 0, btnOprt.Height);
        }

        private void tsmImgConvert_Click(object sender, EventArgs e)
        {
            if (!ShowAskDialog("确认要把前台1.0图片转换为前台2.0格式吗？")) return;
            Thread newThread = new Thread(() => ConvertGoodsImgFrom10());
            newThread.Start();
        }

        /// <summary>
        /// 清一些多余的历史数据
        /// </summary>
        private void ConvertGoodsImgFrom10()
        {
            try
            {
                int index = 1;
                DataExc_SetLog(DateTime.Now.ToString() + string.Format("  图片转换开始。\r\n"));
                FoodUtil foodUtil = new FoodUtil();
                DataExc_ClearProgress();
                var specList = new corecmsfoodspecServices().AsQueryable().Where(p=>p.isDelete == false).ToList();
                DataExc_SetProgressMax(specList.Count);
                foreach (var spec in specList)
                {
                    string fileNameByID = spec.id.ToString() + ".jpg";
                    string path = System.Windows.Forms.Application.StartupPath + "\\LocaleImg";
                    string filename10 = path + "\\" + fileNameByID;
                    if (File.Exists(filename10))
                    {
                        try
                        {
                            string filename20 = path + "\\" + spec.foodId.ToString() + ".jpg";
                            if (File.Exists(filename20)) File.Delete(filename20);
                            if (!Directory.Exists(path)) Directory.CreateDirectory(path);
                            Image sourceImage = Image.FromFile(filename10);
                            Bitmap bmp = new Bitmap(sourceImage, new Size(200, 200));
                            FoodImgService.SaveAsJPEG(bmp, filename20, 100);
                        }
                        catch (Exception ex)
                        {
                            DataExc_SetLog(DateTime.Now.ToString() + string.Format("  错误{0}。\r\n", filename10 + ";" + ex.Message));
                        }
                        finally
                        {
                            GC.Collect();
                        }
                    }

                    DataExc_SetProgress(index);
                    index += 1;
                }
                DataExc_SetLog(DateTime.Now.ToString() + string.Format("  图片转换完成。\r\n"));
            }
            catch(Exception ex) 
            {
                DataExc_SetLog(DateTime.Now.ToString() + string.Format("  错误{0}。\r\n", ex.Message));
            }
        }

        private void tsmSystemLog_Click(object sender, EventArgs e)
        {
            var frm = new frmSystemLog();
            frm.ShowDialog();
            frm.Dispose();
        }

        private void tsmGetGoodsAll_Click(object sender, EventArgs e)
        {
            if (!ShowAskDialog("确定要同步所有商品吗？")) return;
            Task.Factory.StartNew(() =>
            {
                GetGoodsAllAsync();
            }).TaskDis();
        }

        private async void GetGoodsAllAsync()
        {
            var remoteService = new PosRemoteServices(AppConstVars.sysUser.ccessToken);
            string msg = "";

            var exchange = GetCorecmsExchange();
            if (exchange == null)
            {
                DataExc_SetLog(DateTime.Now.ToString() + "  没有找到下载信息数据表，下载中断" + "\r\n");
                return;
            }
            exchange.foodCategoryTime = DateTime.Now.AddDays(-9999);
            exchange.foodTime = DateTime.Now.AddDays(-9999);
            //2、商品分类
            int rowCount = remoteService.GetGoodCategoryList(AppConstVars.sysStore, AppConstVars.sysUser, exchange, ref msg);
            DataExc_SetLog(DateTime.Now.ToString() + "  1、下载更新商品分类资料" + rowCount.ToString() + "条\r\n");

            //3、商品资料
            //List<corecmsfood> foodList = new List<corecmsfood>();
            //rowCount = remoteService.GetGoodDataList(AppConstVars.sysStore, AppConstVars.sysUser, exchange, ref foodList, ref msg);

            var goodsResult = await FoodApiUtil.GetGoodDataList(AppConstVars.sysStore, AppConstVars.sysUser, exchange);
            if ((goodsResult.count > 0) && goodsResult.foodList != null)
            {
                Program.frmOrdering.BindFoodRefresh(goodsResult.foodList);
                new FoodUtil().DownProductImage(goodsResult.foodList);
            }
            DataExc_SetLog(DateTime.Now.ToString() + "  2、下载更新商品资料" + goodsResult.count.ToString() + "条\r\n");
            if ((goodsResult.code == 0) && (!string.IsNullOrEmpty(goodsResult.msg)))
                DataExc_SetLog(DateTime.Now.ToString() + "  3、下载商品=>" + goodsResult.msg.ToString() + "\r\n");
        }

    }
}